<template>
	<view class="">
		<view>
			<view class="search">
				<uni-search-bar placeholder="搜索标题、申请单号" radius="100"></uni-search-bar>
			</view>
		</view>
		<view class="uni-list">
			<checkbox-group @change="checkboxChange">
				<label class="uni-list-cell uni-list-cell-pd" v-for="item in items" :key="item.id">
					<view class="left">
						<checkbox :value="item.id" :checked="item.checked" style="width: 80rpx;height: 80rpx;" />
					</view>
					<view class="center">
						<view class="center-line1">
							<text>{{item.name}}</text><text style="float: right;font-weight: 600;">￥{{item.money}}</text>
						</view>
						<view class="center-line2">
							<text style="font-size: 15rpx;color: #333;">{{item.id}}</text><text style="float: right;color: #333;font-size: 15rpx;">申请金额</text>
						</view>
					</view>
					<view class="right">
						查看
					</view>
				</label>
			</checkbox-group>
		</view>
		<view class="footer">
			<button class="btn" @click="confirm">确定({{sendData.length}})</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'checkbox 复选框',
				items: [
					{
						id: 'S20000006 2020-01-04',
						name: '差旅费申请',
						money: '2000.00',
					},
					{
						id: 'S20000001 2020-01-04',
						name: '报销上海出差',
						money: '703.00',
					}
				],
				sendData:[]
			}
		},
		methods: {
			checkboxChange: function(e) {
				// debugger
				var values = e.detail.value;
				var items=this.items
				this.sendData=[]
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
					if (values.includes(items[i].id)) {
						this.sendData.push(items[i])
					}
				}
			},
			confirm(){
				uni.$emit('relateApply',this.sendData)
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		padding: 30rpx;
		background-color: white;
	}

	.uni-list-cell {
		display: flex;
		justify-content: flex-start;
		height: 100rpx;
		border-bottom: 1rpx solid $underline;
		padding: 30rpx 0;
	}

	.left {
		width: 100rpx;
		height: 100rpx;
	}

	.right {
		width: 100rpx;
		color: $themeColor;
		text-align: center;
		line-height: 100rpx;
	}

	.center {
		flex: 1;
		border-right: 1rpx solid $underline;
	}

	.center-line1 {
		height: 50rpx;
		line-height: 50rpx;
	}

	.center-line2 {
		height: 50rpx;
		line-height: 50rpx;
	}

	/deep/uni-checkbox .uni-checkbox-input {
		height: 60rpx;
		width: 60rpx;
		margin-top: 30rpx;
	}
	.footer{
		width: 92%;
		position: absolute;
		bottom: 0;
	}
	.btn{
		border: 1rpx solid $themeColor;
		background-color:$themeColor;
		color: white;
		bottom: 0;
	}
</style>
